package ac.svn.accesscontrol.controller;

import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import javax.swing.JMenuItem;
import javax.swing.JOptionPane;

import ac.svn.accesscontrol.ui.IUIConstants;
import ac.svn.accesscontrol.ui.JMenu;
import ac.svn.accesscontrol.ui.UIComponentLibrary;
import ac.svn.accesscontrol.ui.XMenuBar;

public class AboutMenuController 
{
	JMenuItem aboutSoftwareMI, aboutDeveloperMI, legalMI;

	public AboutMenuController() 
	{
		initComponents();
	}


	private void registerListeners() 
	{
		aboutSoftwareMI.addActionListener(new ActionListener() {

			@Override
			public void actionPerformed(ActionEvent arg0) 
			{
				String aboutText = "<HTML><p align=\"CENTER\">" +
						"<p align=\"LEFT\"><font size = 16>Software</font></p>" +
						"<br>Official Name: Smart CM" +
						"<br>Version: 1.1.57" +
						"<br>HomePage: Not Available!";
				JOptionPane.showMessageDialog(null, aboutText, "About SmartCM",JOptionPane.INFORMATION_MESSAGE);
			}
		});

		aboutDeveloperMI.addActionListener(new ActionListener() {

			@Override
			public void actionPerformed(ActionEvent arg0) {
				String aboutText = "<HTML><p align=\"CENTER\">" +
						"<p align=\"LEFT\"><font size = 16>Developer</font></p>" +
						"<br> Developed by: Ankush Chaudhary" +
						"<br> Contact developer for feedback or valuable comment at ACRules@gmail.com";

				JOptionPane.showMessageDialog(null, aboutText, "About Developer",JOptionPane.INFORMATION_MESSAGE);

			}
		});

		legalMI.addActionListener(new ActionListener() {

			@Override
			public void actionPerformed(ActionEvent arg0) {
				String aboutText = "<HTML><p align=\"CENTER\">" +
						"<p align=\"LEFT\"><font size = 18>Legal Information</font></p>" +
						"<br>Application uses various Icons which are not created by developer but taken from various websites." +
						"<br>-Majority of icons taken from website \"Icon Finder\" visit: http://www.iconfinder.com "+
						"<br>-Majority of icons belongs to 'Bunch of Bluish Icons' category, author 'mebaze - http://mebaze.com'" +
						"<br>" +
						"<br>Application SmartCM is free for commercial use, yet resources like icons belong to their original authors.";

				JOptionPane.showMessageDialog(null, aboutText, "About Developer",JOptionPane.INFORMATION_MESSAGE);

			}
		});

	}

	private void initComponents() 
	{
		XMenuBar menuBar = (XMenuBar) UIComponentLibrary.getComponent(IUIConstants.C_MENU_BAR);
		if(null != menuBar)
		{
			JMenu aboutMenu = new JMenu("About");
			aboutMenu.setMnemonic('u');

			aboutSoftwareMI = new JMenuItem("Software");
			aboutSoftwareMI.setMnemonic('S');

			aboutDeveloperMI = new JMenuItem("Developer");
			aboutDeveloperMI.setMnemonic('D');

			legalMI = new JMenuItem("Legal");
			legalMI.setMnemonic('L');

			aboutMenu.add(aboutSoftwareMI);
			aboutMenu.add(aboutDeveloperMI);
			aboutMenu.add(legalMI);

			menuBar.add(aboutMenu);

			registerListeners();
		}
	}

}
